executeJavascript

open fun executeJavascript(script: String)

Executes the supplied JavaScript string within the context of the loaded web page. The script is posted to the view's message queue to ensure it runs on the UI thread.

This method is an overload of executeJavascript and does not provide a mechanism to retrieve the result of the script execution. If you need the result, use the other overload.

Parameters

script

The JavaScript code to execute (without the "javascript:" prefix). If null, the method logs a warning and returns without action.

See also


open fun executeJavascript(script: String, @Nullable callback: ValueCallback<String>)

Executes the supplied JavaScript string within the context of the loaded web page and provides a callback for the result. The script is posted to the view's message queue to ensure it runs on the UI thread.

Parameters

script

The JavaScript code to execute (without the "javascript:" prefix). If null, the method returns without action.

callback

A ValueCallback to receive the result of the JavaScript execution. Only supported on Android KitKat (API 19) and above. May be null if no result is needed.